package cst.a526whx.sanjixiangmu_526whx.fragment;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import java.util.ArrayList;
import java.util.List;

import cst.a526whx.sanjixiangmu_526whx.AmicoolListener;
import cst.a526whx.sanjixiangmu_526whx.ArticleAdapter;
import cst.a526whx.sanjixiangmu_526whx.ArticleBean;
import cst.a526whx.sanjixiangmu_526whx.LoginBean;
import cst.a526whx.sanjixiangmu_526whx.R;
import cst.a526whx.sanjixiangmu_526whx.ResModel;


public class ArticleFragment extends Fragment {
    ;
    private RecyclerView recyclerView;
    private ArticleAdapter adapter;
    private List<ArticleBean> list;
    private RecyclerView.LayoutManager layoutManager;
    private AmicoolListener<List<ArticleBean>> listener;
    private ResModel model;
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view=inflater.inflate(R.layout.fragment_article,container,false);
        recyclerView=(RecyclerView)view.findViewById(R.id.article_rec);
        adapter=new ArticleAdapter(getActivity());
        list=new ArrayList<ArticleBean>();
        layoutManager=new LinearLayoutManager(getActivity());
        recyclerView.setLayoutManager(layoutManager);
        recyclerView.setAdapter(adapter);
        listener=new AmicoolListener<List<ArticleBean>>() {
            @Override
            public void onResponse(List<ArticleBean> l) {
                adapter.setList(l);
            }

            @Override
            public void onReponse(LoginBean l) {

            }

            @Override
            public void onFail(String msg) {
                //toast


            }
        };
        model= new ResModel("gson") {
            @Override
            public void reg(String s, String s1, String s2, String rr, String s3, String s4, AmicoolListener listener) {

            }

            @Override
            public void Login(String u, String p, AmicoolListener l) {

            }

            @Override
            public void reg(String u, String p, String t, int roleid, String email) {

            }

            @Override
            public void getList(String mod, int page, String s, AmicoolListener l) {

            }

            @Override
            public void getVideotDetail(String mod, int id, String s, AmicoolListener l) {

            }
        };
        model.getList("article",1,listener);


        return view;
    }
}
